package com.example.uiclassassignments.Activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;

import com.example.uiclassassignments.R;
import com.example.uiclassassignments.tools.GridViewAdapter;
import com.example.uiclassassignments.tools.GridViewItemData;

import java.util.ArrayList;

@SuppressLint("Registered")
public class GirdViewActivity extends Activity {
    private GridView gridView;
    private ArrayList<GridViewItemData> mArrayGridViewItemData=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_grid_view);
        gridView=findViewById(R.id.gridView);
        initData();
        initView();
    }
    protected void initData() {
        mArrayGridViewItemData = new ArrayList<GridViewItemData>();
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_01,"设01"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_02,"设02"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_03,"设03"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_04,"设04"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_05,"设05"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_06,"设06"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_07,"设07"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_08,"设08"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_09,"设09"));
        mArrayGridViewItemData.add(new GridViewItemData(R.mipmap.grid_view_10,"设10"));
    }
    protected void initView() {
        GridViewAdapter gridViewAdapter = new GridViewAdapter(this, mArrayGridViewItemData);
        gridView.setAdapter(gridViewAdapter);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }
}
